package testFestival;

import static org.junit.Assert.*;

import java.io.*;

import player.Player;
import festival.*;
import org.junit.Test;

public class testFestivalWindow {

	@Test
	public void testGreet() throws Exception {
		String data = "\n";
		
		String greet = "Hello unknown\nYou just step in to festival Cell!";
		String prompt = "Press Enter to pick a random Festival: ";
		String expected;
		
		InputStream testInput = new ByteArrayInputStream( data.getBytes("UTF-8") );
		InputStream old = System.in;
		ByteArrayOutputStream testOut = new ByteArrayOutputStream();
		PrintStream testOutPrintStream = new PrintStream(testOut);
		
		String newLine = System.getProperty("line.separator");
		if (newLine == null) newLine = "\n";
		expected = greet + newLine + prompt + newLine;
		System.setOut(testOutPrintStream);
		
		try {
		    System.setIn( testInput );		
		    Player p = new Player();
			festivalWindow testFW = new festivalWindow();
			
			testFW.greet(p);
		} finally {
		    System.setIn( old );
		}
		
		assertEquals(expected, testOut.toString());
	}
}
